﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Default.Master" AutoEventWireup="true" CodeBehind="SearchAddress.aspx.cs" Inherits="MockPrjTeam1.Pages.Views.SearchAddress" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type='text/javascript'>
    function getSelectedItem() {
        var radioes = document.getElementsByClassName('selectradio');
        for (var i = 0; i < radioes.length; i++) {
            if (radioes[i].checked) {
                alert(radioes[i].value);
                window.opener.document.getElementById("AddressId").value = radioes[i].id;
                window.opener.document.getElementById("Address").value = radioes[i].value;
                window.close();
            }
        }
    }
</script>
<script type='text/javascript'>
    function getNoneItem() {
                window.opener.document.getElementById("AddressId").value = "";
                window.opener.document.getElementById("Address").value = "";
                window.close();
    }
</script>
   
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">    
    <div id="templatemo_main">
	
           <div  style="color: #000000; font-weight: bold">
        <br />
    <table class="tablesort">
      <tr>
       <td class="style12">Postcode</td>
        <td class="style12b">
        <asp:TextBox ID="txtPostCode" runat="server" CssClass="textbox3" TabIndex="1"></asp:TextBox>
        </td>
        <td class="style12">Street</td>
        <td class="style12b">
        <asp:TextBox ID="txtStreet" runat="server" CssClass="textbox3" TabIndex="2"></asp:TextBox>
        </td>
        <td class="style12">Town</td>
        <td class="style12b">
        <asp:TextBox ID="txtTown" runat="server" CssClass="textbox3" TabIndex="2"></asp:TextBox>
        </td>
      </tr>
    </table>
      <br />
          <table>
       <tr>
         <td> 
             <asp:Button ID="btnSearch" Text="Search Address" 
                 runat="server" Width="120px" Height="25px" onclick="btnSearch_Click" /></td>
         <td> <input type="button" name="None" value="None" id="btnNone" style="width:65px; height:25px;" onclick="getNoneItem()" /></td>
         <td> <asp:Button ID="btnClear" Text="Clear" runat="server" Width="65px" OnClick="btnClear_Click" 
                 Height="25px" />                 
                 </td>

      </tr>
    </table>
    </div>
    <div>

    <asp:GridView ID="GrVSearchAddress" runat="server" AutoGenerateColumns="False" 
        BorderWidth="1px" Width="100%" AllowPaging="True" DataKeyNames="AddressID" 
            ShowHeaderWhenEmpty="True" OnPageIndexChanging="GrvSearchAddress_PageIndexChanging"  
            EmptyDataText="Chua co du lieu" EnableModelValidation="True" PageSize="10">            
            <Columns>
            <asp:TemplateField HeaderText=""> <ItemTemplate> <center><input type="radio" class="selectradio" id="<%# Eval("AddressID") %>"
    name='SuppliersGroup' value="<%# Eval("Address") %>"> </center>
                </ItemTemplate>
                </asp:TemplateField>
                
                <asp:HyperLinkField DataNavigateUrlFields="addressID" 
                    DataNavigateUrlFormatString="/pages/forms/AddressDetail.aspx?id={0}" 
                    DataTextField="Address" HeaderText="Address">
                <ControlStyle ForeColor="Blue" />
                </asp:HyperLinkField>
                <asp:BoundField DataField="PostCode" HeaderText="Post Code" 
                    SortExpression="PostCode" />
                <asp:BoundField DataField="Town" HeaderText="Town" 
                    SortExpression="Town" />
                <asp:BoundField DataField="County" HeaderText="County" 
                    SortExpression="County" />
                <asp:BoundField DataField="Country" HeaderText="Country" 
                    SortExpression="Country" />                                    
            </Columns> 
            <pagersettings mode="Numeric" position="Bottom" pagebuttoncount="10"/>
            <pagerstyle backcolor="LightBlue"/>     
        </asp:GridView>
    </div>
    <br />

    <table>
          <tr>
             <td> <%--<asp:Button ID="btnSelect" Text="Select" runat="server" Width="65px" 
                     Height="25" />--%>
                  <input type="button" name="Select" value="Select" id="btnSelect" style="width:65px; height:25px;" onclick='getSelectedItem()' />   
                     </td>
             <td> <asp:Button ID="btnCreate" Text="Create" runat="server" 
                     Width="65px" Height="25" style="margin-left: 0px" 
                     onclick="btnCreate_Click" /></td>
          </tr>
    </table> 
    
    <div class="cleaner"></div>
</div> <!-- END of templatemo_main -->
</asp:Content>
